package com.alex.keywordtool;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.util.List;

import org.apache.commons.io.FileUtils;
import org.apache.commons.lang.StringEscapeUtils;

public class GenerateSql {

	public static void main(String[] args) throws Exception {
		List<String> lines = FileUtils.readLines(new File("/home/alex/Desktop/adult_top.txt"));
		BufferedWriter writer = new BufferedWriter(new FileWriter("/home/alex/Desktop/adult_top.sql"));
		writer.write("INSERT INTO adult_keywords (`keyword`) VALUES ");
		
		int n = 0;
		for (String line : lines) {
			writer.write("('" + StringEscapeUtils.escapeSql(line) + "')");
			if (++n != lines.size()) {
				writer.write(",\n");
			}
		}
		
		
		writer.close();
	}

}
